<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 100px;
            background-color: lightblue;
        }
    </style>
</head>

<body>
    <div class="box"></div>
    <script>
        var box = document.querySelector('.box')
        // 监听鼠标按键按下事件
        box.onmousedown = function () {
            console.log('鼠标按键被按下');
        }
        // 监听鼠标按键松开事件
        box.onmouseup = function () {
            console.log('鼠标按键被松开');
        }
    </script>
</body>

</html>